// JavaScript Document
function check(){
	//用户名是否合法验证
	var name = document.getElementById("username");	
	var namevalue = name.value;
	var namelength = namevalue.length;
	if(namelength<6){
		var checkspan = document.getElementById("namecheck");
		checkspan.style.color = "#f33";
		checkspan.innerHTML = "* 用户名长度至少为6";
		name.focus();
		name.select();
	}else{//用户名是否合法
		if(namevalue.search(/^[0-9a-zA-Z]+$/)==-1){
			var checkspan = document.getElementById("namecheck");
			checkspan.style.color = "#f33";
			checkspan.innerHTML = "* 用户名为数字和字母";
			name.focus();
			name.select();
		}else{//检测密码是否合法
			var pw = document.getElementById("password");
			var pwvalue = pw.value;
			var pwlength = pwvalue.length;
			if(pwlength<6 || pwlength > 8){//密码长度是否合法
				var pwspan = document.getElementById("pwcheck");
				pwspan.style.color = "#f33";
				pwspan.innerHTML = "* 密码长度至为6~8";
				pw.focus();
				pw.select();
			}else{//输入规格
				if(pwvalue.search(/^[0-9a-zA-Z]+$/)==-1){
					var pwspan = document.getElementById("pwcheck");
					pwspan.style.color = "#f33";
					pwspan.innerHTML = "* 密码应该为字母和数字";
					pw.focus();
					pw.select();
				}else{//检测两次输入的密码是否相等
					if(pwvalue != document.getElementById("pwagain").value){
						var pwspan = document.getElementById("pwcheck");
						pwspan.style.color = "#f33";
						pwspan.innerHTML = "* 两次输入的密码不匹配";
						pw.focus();
						pw.select();
					}else{//Email判断
						var email = document.getElementById("email");
						var emailvalue = email.value;
						var re= /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
						if(emailvalue == ""){							
							var emailcheck = document.getElementById("emailcheck");
							emailcheck.style.color = "#f33";
							emailcheck.innerHTML = "*  电子邮件不能为空";
						}else if(re.test(emailvalue)){
							if(document.getElementById("agree").checked){
								//window.alert(document.getElementById("gender").value);
								var boy = document.getElementById("boy");
								var girl = document.getElementById("girl");
								if(boy.checked){
									document.getElementById("gender").value = boy.value;
									document.forms("signinform").submit();	
								}else{
									document.getElementById("gender").value = girl.value;	
									document.forms("signinform").submit();
								}
									
							}else{
								window.alert("对不起！在您不同意协议的情况下，我们不能提供注册！");
							}
						}else{
							var emailcheck = document.getElementById("emailcheck");
							emailcheck.style.color = "#f33";
							emailcheck.innerHTML = "*  电子邮件格式不合法";	
						}
					}
				}
			}
		}
	}
}
// boycheck
function boychecked(){
	var boy = document.getElementById("boy");
	var girl = document.getElementById("girl");
	boy.checked = true;
	if(boy.checked){
		girl.checked = false;
	}
}
//girlcheck
function girlchecked(){
	var boy = document.getElementById("boy");
	var girl = document.getElementById("girl");
	girl.checked = true;
	if(girl.checked){
		boy.checked = false;
	}	
}